import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/20 11:02
 */

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt(), q = in.nextInt();
            int[] arr = new int[n + 1];
            for (int i = 1; i < n + 1; i++) {
                arr[i] = in.nextInt();
            }

            //预处理一个前缀和数组
            long[] dp = new long[n + 1];
            for (int i = 1; i < n + 1; i++) {
                dp[i] = dp[i - 1] + arr[i];
            }

            //使用前缀和数组
            while (q > 0) {
                int l = in.nextInt(), r = in.nextInt();
                System.out.println(dp[r] - dp[l - 1]);
                q--;
            }
        }
    }
}